// const http = require('http');
const express = require('express')
var bodyParser = require('body-parser')
const app = express()
//解析body中间件
const port = 3000

app.use(bodyParser.json({ limit: '100mb' }))


// //设置跨域访问
// app.all('*',function(req,res,next){
//   res.header("Access-Control-Allow-Origin","*");//允许的域名
//   res.header('Access-Control-Allow-Origin','PUT,GET,POST,DELETE,OPTIONS');//允许的请求方式
//   res.header("Access-Control-Allow-Origin","X-Requested-with");//允许的header
//   res.header('Access-Control-Allow-Origin','Content-Type,token');//header
//   next();
// });
app.all('*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length,token, Authorization, Accept, X-Requested-With , yourHeaderFeild');
  res.header("X-Powered-By",' 3.2.1')
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
  });

//wx
const wxRouter = require('./wx')
wxRouter(app)

//admin
const adminRouter = require('./admin')
adminRouter(app)

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})
